home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / hardware / summa / sys / shmiq.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  6.4 KB  |  191 lines

  1. /*
  2.  * Copyright (C) 1990, 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #ifndef __SYS_SHMIQ_H__
  18. #define __SYS_SHMIQ_H__
  19.  
  20. /*
  21.  * Internals for the shared memory input queue driver
  22.  */
  23. #ident "$Revision: 1.4 $"
  24.  
  25. #include "sys/poll.h"
  26. /*
  27.  * The data is ALMOST never interpreted.  The exception is for cursor
  28.  * tracking.    If the type field is '0' (IDEV_PTR_EVENT), then
  29.  * u.ptraxis[0] and u.ptraxis[1] contain pointer coordinates which
  30.  * are sent to the "setscr" stuff designated stream.
  31.  */
  32. struct shmqdata {
  33.     unsigned char device ;        /* device major */
  34.     unsigned char which ;        /* device minor */
  35.     unsigned char type ;        /* event type */
  36.     unsigned char flags ;        /* little event data */
  37.     union {
  38.         long int pos ;        /* big event data */
  39.         short ptraxis[2] ;        /* event data for PTR events */
  40.     } un;
  41. } ;
  42.  
  43. /* Data structure for intra-kernel verification ( addressability ) */
  44. struct shmiqlinkid {
  45.     short int devminor ;    /* Identifies the shmiq */
  46.     short int index ;    /* Identifies the device */
  47. } ;
  48.  
  49. struct shmqevent {
  50.     union {
  51.         long int time ;        /* 10 millisecond units from lbolt */
  52.         struct shmiqlinkid id ;
  53.     } un ;
  54.     struct shmqdata data ;
  55. } ;
  56.  
  57. struct sharedMemoryInputQueue {
  58.     volatile long int head ;        /* user's index into events */
  59.     volatile long int tail ;        /* kernel's index into events */
  60.     volatile unsigned long int flags ;    /* place for out-of-band data */
  61.     struct shmqevent events[1] ;        /* input event buffer */
  62. } ;
  63. /* flags' bits */
  64. #define SHMIQ_OVERFLOW    0x00000001
  65. #define SHMIQ_CORRUPTED 0x00000002
  66.  
  67. #ifdef _KERNEL
  68.  
  69. /* At "I_LINK" time, a M_PCPROTO message with this is sent to the lower
  70.  * stream to see if he plays by the "shmiq" rules.  The correct response
  71.  * is to "qreply" with a M_PCPROTO with "mtype" changed from "SHMIQ_NOTICE"
  72.  * to "SHMIQ_PLAY".
  73.  */
  74. #define SHMIQ_NOTICE ( ( 'S' << 24 ) | ( 'H' << 16 ) | ( 'M' << 8 ) | 'Q' )
  75. #define SHMIQ_PLAY   ( 'S' | ( 'H' << 8 ) | ( 'M' << 16 ) | ( 'Q' << 24 ) )
  76. struct shmqntc {
  77.     unsigned long int mtype ;
  78.     struct shmiqlinkid id ;
  79. } ;
  80.  
  81. struct cursorTrack { /* Used for kernel cursor tracking */
  82.     int status ;
  83.     long int x ;        /* cursor X */
  84.     long int y ;        /* cursor Y */
  85.     /* We can't filter at the source or the locator won't move */
  86.     long int filterULX ;    /* don't care box minimum cursor X */
  87.     long int filterULY ;    /* don't care box minimum cursor Y */
  88.     long int filterLRX ;    /* don't care box maximum cursor X */
  89.     long int filterLRY ;    /* don't care box maximum cursor Y */
  90. } ;
  91.  
  92. struct shmq {
  93.     struct sharedMemoryInputQueue *q ; /* kernel space pointer */
  94.     long int qtail ;        /* private copy the user can't break */
  95.     long int qsize ;        /* record at attach time */
  96.     struct proc *owner ;        /* proccess attached to */
  97.     caddr_t user_vaddr ;        /* location in owner's proccess space */
  98. } ;
  99.  
  100. /* Chain for "I_LINK"'ed lower streams */
  101. struct shmiqlink {
  102.     struct shmiq *up ;
  103.     struct shmiqlinkid id ;
  104.     queue_t *lwq ;        /* top write queue of lower stream */
  105.     queue_t *lrq ;        /* top read queue of lower stream */
  106.     struct shmiq *mux ;
  107.     int l_index ;        /* system ID from struct linkblk */
  108.     int l_flags ;        /* flags specific to this device */
  109. } ;
  110.  
  111. struct shmiq {
  112.     /* Event Queue stuff */
  113.     struct shmq qd ;        /* Connection data for user's queue */
  114.     struct cursorTrack locator ;    /* Used for kernel cursor tracking */
  115.     unsigned int currentScreen ;    /* Where to send cursor motion */
  116.  
  117.     /* Streams stuff */
  118.     queue_t *urq ;            /* top read queue of upper stream */
  119. #define MAX_MUX_LINKS 16 /* Should be a dynamic parameter, but ... */
  120.     struct shmiqlink *linkrecord[MAX_MUX_LINKS] ;
  121.  
  122.     /* spin lock for access */
  123.     lock_t alck ;            /* always acquired by "trading" */
  124.                     /* for the "shmiq_lock" */
  125.  
  126.     /* Misc. Std. Driver stuff */
  127.     int status ;
  128. /* possible status values -- OR'ed together */
  129. #define SHMIQ_STR_INIT 1
  130. #define SHMIQ_CHAR_INIT    2
  131.  
  132.     int stroflag ;
  133.     int deviceminor ;        /* To find our way back */
  134.     struct pollhead selproc ;        /* For selwakeup */
  135. } ;
  136.  
  137. /* Stuff from master.d/shmiq */
  138. extern int shmiq_cnt ; /* Actual number */
  139. extern lock_t shmiq_lock ; /* Controls all access to the array */
  140. extern struct shmiq *dev_shmiq[] ;
  141.  
  142. #define SHMIQ_POSCURSOR ( ( 'S' << 24 ) | ( 'H' << 16 ) | ( 'I' << 8 ) | 'Q' )
  143.  
  144. #endif /* _KERNEL */
  145.  
  146. /* USER VISIBLE */
  147. #define SHMIQ_MINSIZE 100 /* Minimum size of queue in number of events */
  148.  
  149. struct muxioctl {    /* for QIOCMUXIOC */
  150.     int index ;    /* index of lower stream */
  151.     int realcmd ;    /* subdevice IOCTL command */
  152. } ;
  153.  
  154. struct shmiqreq {        /* for QIOCATTACH */
  155.     char *user_vaddr ;    /* starting address to lock down for a shmiq */
  156.     int arg ;        /* size of queue event array */
  157. } ;
  158.  
  159. #define    SHMIQ_LINK_CURSX    0x1
  160. #define    SHMIQ_LINK_CURSY    0x2
  161. #define    SHMIQ_LINK_CURSOR    0x3
  162. struct shmiqsetcurs {    /* for QIOCSETCURS */
  163.     short index ;    /* index of device */
  164.     short axes ;    /* axes we care about (SHMIQ_LINK_CURS[XY]) */
  165. } ;
  166.  
  167. struct shmiqsetcpos {    /* for QIOCSETCPOS */
  168.     short    x ;
  169.     short    y ;
  170. } ;
  171.  
  172. /* ioctl cmds */
  173. #define QIOCATTACH    _IOW('Q',1,struct shmiqreq)    /* map memory */
  174. #define QIOCDETACH    _IO('Q',2)            /* unmap memory */
  175. #define QIOCSERVICED    _IO('Q',3)        /* acknowledge overflow */
  176. #define QIOCURSTRK    _IOW('Q',4,int)        /* set cursor tracking mode */
  177. #define QIOCURSIGN    _IOW('Q',5,long int[4])    /* set cursor filter box */
  178. #define QIOCSETSCRN    _IOW('Q',6,int)        /* set curent screen */
  179. #define QIOCIISTR    _IOW('Q',7, struct muxioctl)/* double indirect I_STR */
  180. #define QIOCGETINDX    _IOWR('Q',8,int)    /* get index from l_index */
  181. #define    QIOCSETCURS    _IOWR('Q',9,struct shmiqsetcurs ) /* set cursor axes */
  182. #define    QIOCSETCPOS    _IOWR('Q',10,struct shmiqsetcpos ) /* set cursor position */
  183.  
  184. /* QIOCURSTRK mode values -- or'ed together */
  185. #define SHMIQ_CURSOR_TRACKED 1
  186. #define SHMIQ_CURSOR_ASYNC 2    /* Tracks physical device */
  187. #define SHMIQ_CURSOR_SYNC  0    /* Tracks logical device */
  188. #define SHMIQ_CURSOR_FILTER 4    /* use ignore box ? (arm trigger) */
  189.  
  190. #endif /* __SYS_SHMIQ_H__ */
  191.